package com.sakura.hk.sakura.springboot.plugin;

import com.sakura.hk.sakura.springboot.plugin.config.SakuraPluginConfig;
import org.gradle.api.Project;

import java.io.File;

/**
 * 插件的配置项
 *
 * @Author: 贺坤
 * @Date: 2021/7/13 13:53
 */
public class SakuraExtension {
    /**
     * 项目对象
     */
    private Project project;
    /**
     * 编译路径
     */
    private File compileDir;
    /**
     * 缓存目录
     */
    private File cacheDir;
    /**
     * 缓存目录名称
     */
    private String cacheName = SakuraPluginConfig.CACHE_NAME;
    /**
     * 构建目录
     */
    private File buildDir;
    /**
     * 构建jar名称
     */
    private String buildJarName;
    /**
     * 插件启动类 类名
     */
    private String myLauncherName = SakuraPluginConfig.MY_LAUNCHER_NAME;
    /**
     * 包名
     */
    private String myLauncherPackageName = SakuraPluginConfig.MY_LAUNCHER_PACKAGE_NAME;
    /**
     * 插件路径属性
     */
    private String pluginPathProperty = SakuraPluginConfig.PLUGIN_PATH_PROPERTY;
    /**
     * 插件文件夹属性
     */
    private String pluginPathNameProperty = SakuraPluginConfig.PLUGIN_NAME_PROPERTY;
    /**
     * 默认插件所在文件夹名称
     */
    private String pluginPathName = SakuraPluginConfig.PLUGIN_PATH_NAME;
    /**
     * Springboot 启动类的jar包路径
     */
    private String springBootLoaderJarPath = null;
    /**
     * 生成jar包后缀
     */
    private String suffix = SakuraPluginConfig.SUFFIX;
    /**
     * 是否删除缓存
     */
    private Boolean delCache = true;
    /**
     * 是否开启自定义模式
     */
    private Boolean custom = false;
    /**
     * 打包类型
     */
    private SakuraBootType type =SakuraBootType.JAR;


    /**
     * 初始化类
     *
     * @param project gradle 项目对象
     */
    public SakuraExtension(Project project) {
        this.project = project;
        this.compileDir = project.getBuildDir();
        this.buildDir = new File(compileDir, "libs");
        this.cacheDir = new File(compileDir, "libs");
    }


    public File getCompileDir() {
        return compileDir;
    }

    public void setCompileDir(File compileDir) {
        this.compileDir = compileDir;
    }

    public File getCacheDir() {
        return cacheDir;
    }

    public void setCacheDir(File cacheDir) {
        this.cacheDir = cacheDir;
    }

    public String getCacheName() {
        return cacheName;
    }

    public void setCacheName(String cacheName) {
        this.cacheName = cacheName;
    }

    public File getBuildDir() {
        return buildDir;
    }

    public void setBuildDir(File buildDir) {
        this.buildDir = buildDir;
    }

    public String getBuildJarName() {
        return buildJarName==null?project.getName() + "-" + project.getVersion():buildJarName;
    }

    public void setBuildJarName(String buildJarName) {
        this.buildJarName = buildJarName;
    }

    public Project getProject() {
        return project;
    }

    public String getMyLauncherName() {
        return myLauncherName;
    }

    public void setMyLauncherName(String myLauncherName) {
        this.myLauncherName = myLauncherName;
    }

    public String getMyLauncherPackageName() {
        return myLauncherPackageName;
    }

    public void setMyLauncherPackageName(String myLauncherPackageName) {
        this.myLauncherPackageName = myLauncherPackageName;
    }

    public String getPluginPathProperty() {
        return pluginPathProperty;
    }

    public void setPluginPathProperty(String pluginPathProperty) {
        this.pluginPathProperty = pluginPathProperty;
    }

    public String getPluginPathName() {
        return pluginPathName;
    }

    public void setPluginPathName(String pluginPathName) {
        this.pluginPathName = pluginPathName;
    }

    public String getSpringBootLoaderJarPath() {
        return springBootLoaderJarPath;
    }

    public void setSpringBootLoaderJarPath(String springBootLoaderJarPath) {
        this.springBootLoaderJarPath = springBootLoaderJarPath;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public Boolean getDelCache() {
        return delCache;
    }

    public void setDelCache(Boolean delCache) {
        this.delCache = delCache;
    }

    public Boolean getCustom() {
        return custom;
    }

    public void setCustom(Boolean custom) {
        this.custom = custom;
    }

    public String getPluginPathNameProperty() {
        return pluginPathNameProperty;
    }

    public void setPluginPathNameProperty(String pluginPathNameProperty) {
        this.pluginPathNameProperty = pluginPathNameProperty;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    public SakuraBootType getType() {
        return type;
    }

    public void setType(SakuraBootType type) {
        this.type = type;
    }
}
